package com.alibaba.otter.node.etl.autoconfigure;

import com.alibaba.otter.node.common.communication.NodeCommunicationClient;
import com.alibaba.otter.node.common.config.ConfigClientService;
import com.alibaba.otter.node.etl.conflict.FileBatchConflictDetectService;
import com.alibaba.otter.node.etl.conflict.impl.FileBatchConflictDetectServiceImpl;
import com.alibaba.otter.shared.common.utils.thread.ExecutorTemplateGetter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration(proxyBeanMethods = false)
public class NodeConflictAutoConfiguration {

    @Bean
    public FileBatchConflictDetectService fileBatchConflictDetectService(ConfigClientService configClientService,
                                                                         NodeCommunicationClient nodeCommunicationClient,
                                                                         ExecutorTemplateGetter executorTemplateGetter) {
        FileBatchConflictDetectServiceImpl fileBatchConflictDetectService = new FileBatchConflictDetectServiceImpl();
        fileBatchConflictDetectService.setRetry(3);
        fileBatchConflictDetectService.setExecutorTemplateGetter(executorTemplateGetter);
        fileBatchConflictDetectService.setConfigClientService(configClientService);
        fileBatchConflictDetectService.setNodeCommunicationClient(nodeCommunicationClient);
        return fileBatchConflictDetectService;
    }

}
